package com.catering.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.catering.entity.CateringGoods;
import com.catering.entity.vo.CateringGoodsVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CateringGoodsDao extends BaseMapper<CateringGoods> {

    @Select("select t1.*,t2.sys_id spaces_id from catering_goods t1 left join catering_spaces t2 on t1.sys_id = t2.goods_id ${ew.customSqlSegment}")
    public IPage<CateringGoodsVo> selectPageList(IPage<CateringGoods> page, @Param(Constants.WRAPPER) QueryWrapper<CateringGoods> queryWrapper);

    @Select("select count(1) from catering_goods t1 left join catering_spaces t2 on t1.sys_id = t2.goods_id ${ew.customSqlSegment}")
    public int selectPageCount(@Param(Constants.WRAPPER) QueryWrapper<CateringGoods> queryWrapper);

    @Select("select t1.*,t2.sys_id spaces_id from catering_goods t1 left join catering_spaces t2 on t1.sys_id = t2.goods_id ${ew.customSqlSegment}")
    public List<CateringGoodsVo> selectNoPageList(@Param(Constants.WRAPPER) QueryWrapper<CateringGoods> queryWrapper);
    
    @Select("select distinct(product_type) product_type from catering_goods ${ew.customSqlSegment} order by product_type asc")
    public List<CateringGoods> selectDisc(@Param(Constants.WRAPPER) QueryWrapper<CateringGoods> queryWrapper);
}
